package com.woniuxy.joylifeshop.controller;

import com.woniuxy.joylifeshop.service.PictureService;
import com.woniuxy.joylifeshop.vo.ResponseInformation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
public class PictureController {

    @Autowired
    PictureService pictureService;
    /**
    * @Author SooYoo
    * @Description 上传照片
    * @Param
    * @Return
    **/
    @RequestMapping("/pictureUpdate")
    public ResponseInformation addImg(MultipartFile img,String imgId) {
        ResponseInformation responseInformation = new ResponseInformation();


        try {
            //获得链接
            String src = pictureService.addPictureService(img);
            //存入数据库
            pictureService.insertPicture(src,imgId);

            responseInformation.setData(src);



            return responseInformation;
        } catch (Exception e) {
            e.printStackTrace();


            return responseInformation;
        }
    }




}
